#define _CRT_SECURE_NO_WARNINGS  1
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;


class Gift {
public:
    int getValue(vector<int> gifts, int n)
    {
        map<int, int> m;
        for (auto ch : gifts)
        {
            m[ch]++;
        }

        int stand = n / 2;
        for (auto ch : m)
        {
            if (ch.second >= stand)
            {
                return ch.first;
            }
        }

        return 0;
    }
};


using namespace std;

int getLevenshtein(const string& s1, const string& s2)
{   
    int m = s1.size();
    int n = s2.size();
    vector<vector<int>> dp(m + 1, vector<int>(n + 1));
    int ret = 0;
    for (int i = 1; i < m + 1; i++)
    {
        for (int j = 1; j < n + 1; j++)
        {
            if (s1[i - 1] == s2[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1; 
                ret = max(ret, dp[i][j]);
            }
            
        }
    }
     
}

int main()
{
    string s1;
    string s2;
    cin >> s1 >> s2;
    cout << getLevenshtein(s1, s2);
    int count = 0;
}